//
//  main.c
//  打印杨辉三角
//
//  Created by apple on 2017/1/6.
//  Copyright © 2017年 apple. All rights reserved.
#include <stdio.h>
int main(){
    int N,i,j,n,m;
    int a[15][15];
    scanf("%d",&N);
    for (i=0; i<N; i++) {
        scanf("%d",&j);
        
        for (m=0; m<j;m++ ) {
            a[m][m]=1;
        }
        for (n=0; n<j; n++) {
            a[0][n]=1;
        }
        for (m=2; m<j;m++ ) {
            for (n=1; n<n-1; n++) {
                a[m][n]=a[m-1][n]+a[m-1][n-1];
            }
        }
        
        for (m=0; m<j;m++ ) {
            
            for (n=0; n<=m; n++) {
                printf("%d ",a[m][n]);
            }
            
            
            printf("\n");
        }
    }
    
}